package xyz.jangle.design.prototype;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class ConcretePrototype3 implements Prototype, Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 7486786403960307872L;
	private AAA aaa;

	public AAA getAaa() {
		return aaa;
	}

	public void setAaa(AAA aaa) {
		this.aaa = aaa;
	}
	
	@Override
	public Object cloneSelf() throws CloneNotSupportedException {
		Object object = null;
		try {
			ByteArrayOutputStream out1 = new ByteArrayOutputStream();
			ObjectOutputStream out2 = new ObjectOutputStream(out1);
			out2.writeObject(this);
			ByteArrayInputStream in1 = new ByteArrayInputStream(out1.toByteArray());
			ObjectInputStream in2 = new ObjectInputStream(in1);
			object = in2.readObject();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return object;
	}

}
class AAA implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 963011062357603854L;
	private int a,b;

	public int getA() {
		return a;
	}

	public void setA(int a) {
		this.a = a;
	}

	public int getB() {
		return b;
	}

	public void setB(int b) {
		this.b = b;
	}
	
	
	
}


